home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 4.1 KB | 149 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMemMgr.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWMEMMGR_H
- #define FWMEMMGR_H
-
- #include <stddef.h>
-
- #ifndef FWSTDDEF_H
- #include "FWStdDef.h"
- #endif
-
- #ifndef FWPRIEXC_H
- #include "FWPriExc.h"
- #endif
-
- #ifndef FWEXCDEF_H
- #include "FWExcDef.h"
- #endif
-
- #ifndef FWNEW_H
- #include "FWNew.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__MEMORY__)
- #include <Memory.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__ERRORS__)
- #include <Errors.h>
- #endif
-
- #ifdef FW_BUILD_WIN32
-
- #include <Windows.h>
-
- // Windows 32 API macro that conflicts with a method in FW_CMemoryManager
- #ifdef CopyMemory
- #undef CopyMemory
- #endif
-
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- #if defined(FW_BUILD_MAC)
- const FW_PlatformError FW_xMemoryExhausted = memFullErr;
- #elif defined(FW_BUILD_WIN)
- const FW_PlatformError FW_xMemoryExhausted = -30999; //!!!JEL: Need correct value!!!
- #endif
-
-
- //========================================================================================
- // Forward class declarations
- //========================================================================================
-
- struct MemHeap;
-
- //========================================================================================
- // Type definitions
- //========================================================================================
-
- typedef void (*FW_PFVV)();
- // Pointer to function returning void.
- // Used with set_new_handler. See ARM, pp 280-81.
-
- //========================================================================================
- // Global procedure definitions
- //========================================================================================
-
- void* operator new(size_t size);
- void operator delete(void* block);
-
- #ifdef FW_SET_NEW_HANDLER
- FW_PFVV set_new_handler(FW_PFVV handler);
- // See ARM, pp 280-81.
- #endif
-
- #ifdef FW_BUILD_MAC
- void SetStackSpace(long numBytes);
-
- // MetroWerks won't compile this, don't know if we use it? [AMB]
- //pascal Ptr GetCurrentStackBase() = { /* kMoveLAbsolute */ 0x2eb8,
- // /* CurStackBase */ 0x0908 };
- // /* MOVE.L CurStackBase,(SP) */
- #endif
-
- //========================================================================================
- // CLASS FW_CMemoryManager
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CMemoryManager
- {
- public:
-
- // Utility routines for manipulating blocks of memory
- static void CopyMemory(const void* const source,
- void* const destination,
- unsigned long bytesToMove);
- static void SetMemory(void* aBlock,
- unsigned long bytesToSet,
- unsigned char byteValue);
- static void* AddOffsetToPointer(void* pointer,
- unsigned long Offset);
-
- // when resizable, pointer-based blocks are needed:
- static void* AllocateBlock(unsigned long bytesRequested);
- static void* ResizeBlock(void* aBlock,
- unsigned long bytesRequested);
- static void FreeBlock(void* aBlock);
-
- // when platform specific handles are needed:
- static FW_PlatformHandle AllocateSystemHandle(unsigned long bytesRequested);
- static FW_PlatformHandle ResizeSystemHandle(FW_PlatformHandle aHandle,
- unsigned long bytesRequested);
- static void FreeSystemHandle(FW_PlatformHandle aHandle);
- static void* LockSystemHandle(FW_PlatformHandle aHandle);
- static void UnlockSystemHandle(FW_PlatformHandle aHandle);
- static unsigned long GetSystemHandleSize(FW_PlatformHandle aHandle);
- static FW_PlatformHandle CopySystemHandle(FW_PlatformHandle aHandle);
-
- //internal methods
- // when resizable, pointer-based blocks are needed, no debug checking:
- static void InitializeRawBlock(void* aBlock,
- unsigned long sizeBlock);
-
- static void DefaultNewHandler();
-
- private:
- static MemHeap* GetMemoryHeap();
-
- FW_CMemoryManager() {};
- // abstract class. Note that all methods are statics.
- };
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-